
function warning(obj, msg) {
            obj.html('<font color="red">'+msg+'</font>');
        }
        function ok(obj, msg) {
            obj.html('<font color="green">'+msg+'</font>');
        }
        function setstatus(namestau,failed){
            $('#'+namestau+'').val(failed);
        }
        String.prototype.Trim=function(){
                    return this.replace(/(^\s*)|(\s*$)/g, "");
                }
//检测用户名
function checkusername(){
				var textval = $('#username').val().Trim();
                
                var temp = /^[A-Za-z0-9]+$/;
                var flag = temp.test(textval);
                var cu = $('#usernamemsg');
                if(textval=='') {
                warning(cu, '用户名不能为空');
                setstatus('usernamestau','failed');
								onfocus="this.blur()";
                }else if(!flag){
                warning(cu, '请输入字母或数字');
                setstatus('usernamestau','failed');
								onfocus="this.blur()";
                }else if(textval.length > 12 || textval.length <4 ){
                    warning(cu, '确认用户名为4-12位');
                    setstatus('usernamestau','failed');
										onfocus="this.blur()";
                }else{
                ok(cu,'输入正确');
                setstatus('usernamestau','pass');
            }

	}
	//检测密码
function checkpassword(){
            var passwd1 = $('#password').val().Trim();
            var cu = $('#passwordmsg');
            if(passwd1 == ''){
                warning(cu,'密码不能为空');
                setstatus('passwordstau','failed');
								onfocus="this.blur()";
            }else if(passwd1.length <6 || passwd1.length>12){
                    warning(cu, '确认密码为6-12位');
                    setstatus('passwordstau','failed');
										onfocus="this.blur()";
            }else{
                ok(cu,'设置正确');
                setstatus('passwordstau','pass');
            }

        }
				//检测确认密码
function checkpass2(){
            var passwd1 = $('#password').val().Trim();
            var passwd2 = $('#pwdconfirm').val().Trim();
            var cu = $('#pwdconfirmmsg');
            if(passwd2 == ''){
                warning(cu,'密码不能为空');
                setstatus('pwdconfirmstau','failed');
                onfocus="this.blur()";
            }else if(passwd1!=passwd2){
                warning(cu,'密码与第一次输入不同');
                setstatus('pwdconfirmstau','failed');
                onfocus="this.blur()";
            }
            else{
                ok(cu,'输入正确');
                setstatus('pwdconfirmstau','pass');
            }

        }
				
				function isemail() {
            //alert ('ooooo');
            var email = $('#email').val().Trim();
            var cu = $('#emailmsg');
            var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
            if(email == ''){
                warning(cu,'邮箱不能为空');
                setstatus('emailstau','failed');

            }else if(!reg.test(email)){
                warning(cu,'邮箱格式不正确');
                setstatus('emailstau','failed');
            }else{
                 ok(cu,'输入正确');
                setstatus('emailstau','pass');   
            }
        }
 function checkre(){
            var passwordstau  = $('#passwordstau').val().Trim();
            var pwdconfirmstau = $('#pwdconfirmstau').val().Trim();
            var usernamestau = $('#usernamestau').val().Trim();
            var emailstau = $('#emailstau').val().Trim();
            if(passwordstau == 'pass' && pwdconfirmstau =='pass' && usernamestau =='pass' && emailstau =='pass'){
                return true;
            }else{
                alert('请正确填写信息');
                return false;
            }

        }
				
				
				function checkmobile(){
                var telephoneval = $('#tel').val().Trim();
                var tmp = /^1[3-9]\d{9}$/;     //支持11位手机号码验证
                //var tel = /^\d{3,4}-?\d{7,9}$/;
                var flag=tmp.test(telephoneval);
                var cu = $('#telmsg');
                if(telephoneval==''){
                    warning(cu, '手机号码不能为空');
                    setstatus('telstau','failed');
                }else if(!flag) {
                    warning(cu, '请输入正确手机手机号码');
                    setstatus('teltau','failed');
                }else{
                  ok(cu, '输入正确');
                  setstatus('telstau','pass');
                           
                }
            }
			
				function checkqq(){
                var qq = $('#qq').val().Trim();
                var tmp = /^[1-9]\d{4,8}$/;     
               
                var flag=tmp.test(qq);
                var cu = $('#qqmsg');
                if(qq==''){
                    warning(cu, 'qq号码不能为空');
                    setstatus('qqstau','failed');
                }else if(!flag) {
                    warning(cu, '请输入正确qq号码');
                    setstatus('qqstau','failed');
                }else{
                  ok(cu, '输入正确');
                  setstatus('qqstau','pass');
                           
                }
            }
			function checkrelvshi(){
            var passwordstau  = $('#passwordstau').val().Trim();
            var pwdconfirmstau = $('#pwdconfirmstau').val().Trim();
            var usernamestau = $('#usernamestau').val().Trim();
            var emailstau = $('#emailstau').val().Trim();
						var qqstau = $('#qqstau').val().Trim();
						var telstau = $('#telstau').val().Trim();
						
            if(passwordstau == 'pass' && pwdconfirmstau =='pass' && usernamestau =='pass' && emailstau =='pass' && qqstau=='pass' && telstau=='pass'){
                return true;
            }else{
                alert('请正确填写信息');
                return false;
            }

        }	
				function checkrelvsuo(){
            var passwordstau  = $('#passwordstau').val().Trim();
            var pwdconfirmstau = $('#pwdconfirmstau').val().Trim();
            var usernamestau = $('#usernamestau').val().Trim();
            var emailstau = $('#emailstau').val().Trim();
						//var qqstau = $('#qqstau').val().Trim();
						var telstau = $('#telstau').val().Trim();
						
            if(passwordstau == 'pass' && pwdconfirmstau =='pass' && usernamestau =='pass' && emailstau =='pass' && telstau=='pass'){
                return true;
            }else{
                alert('请正确填写信息');
                return false;
            }

        }	
				//检测咨询标题
				function checktitle(){
					
								var textval = $('#title').val().Trim();
				                
				                var temp = /^[\u4e00-\u9fa5]*$/;
				                
				                var flag = temp.test(textval);
				                var cu = $('#titlemsg');
				                if(textval=='') {
				                warning(cu, '标题不能为空');
				                setstatus('titlestau','failed');
												onfocus="this.blur()";
				                }else if(!flag){
				                warning(cu, '请输入汉字');
				                setstatus('titlestau','failed');
												onfocus="this.blur()";
				                }else if(textval.length > 36 || textval.length <2 ){
				                    warning(cu, '请输入标题为2-36位');
				                    setstatus('titlestau','failed');
									onfocus="this.blur()";
				                }else{
				                ok(cu,'输入正确');
				                setstatus('titlestau','pass');
				            }

					}		
				
				//检测咨询内容
				function checkzixun_content(){
								var textval = $('#content').val().Trim();
								log=textval.length;
							
								var cu = $('#zixuncontentmsg');
				                if(textval=='') {
				                warning(cu, '内容不能为空');
				                setstatus('zixuncontentstau','failed');
								onfocus="this.blur()";
				                }else if(textval.length < 6 ){
				                    warning(cu, '请输入至少6个汉字');
				                    setstatus('zixuncontentstau','failed');
									onfocus="this.blur()";
				                }else{
				                ok(cu,'输入正确');
				                setstatus('zixuncontentstau','pass');
				            }

					}
				//检测咨询
				function checkrezixun(){
		            
		            var titlestau = $('#titlestau').val().Trim();
		            var zixuncontentstau = $('#zixuncontentstau').val().Trim();
		            if(titlestau == 'pass' && zixuncontentstau =='pass'){
		                return true;
		            }else{
		                alert('请正确填写信息');
		                return false;
		            }

		        }	
				